<?php 
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Google地图控制器
 * 
 * @author 	FangMinglong
 * @date 	2017-04-17 17:18
 */
class Googlemap extends MY_Controller {

	private $ak;

	public function __construct() {
		parent::__construct();
		
		$this->config->load('google');
		
		$this->ak = $this->config->item('key', 'api');
		
		// IOS 3166-1 Alpha-2
		$this->countryMap = [
			'AU' => 'Australia',
			'BR' => 'Brazil',
			'CA' => 'Canada',
			'FR' => 'France',
			'DE' => 'Germany',
			'MX' => 'Mexico',
			'NZ' => 'New Zealand',
			'IT' => 'Italy',
			'ZA' => 'South Africa',
			'CN' => 'China',
			'ES' => 'Spain',
			'PT' => 'Portugal',
			'US' => 'U.S.A.',
			'UK' => 'United Kingdom',
		];
	}

	public function index() {
		
		$data['title'] = 'Google Map';
		
		$data['demoList'] = [
			'maps_javascript_api_show' => '地图显示 || 标记聚类-聚合点地图 || 将数据导入地图 || 可视化数据：绘制地震图',
			'maps_javascript_api_geolocation' => '地理定位：在地图上显示用户或设备位置-Error: The Geolocation service failed.???',
			'maps_javascript_api_others' => '其它功能',
			'maps_javascript_api_places' => '地址和搜索自动完成 - 地址和搜索请求',
			'maps_javascript_api_places_autocomplete' => '地址和搜索自动完成 - 搜索自动完成',

			'maps_javascript_api_events_picker' => '地图选点 经纬度（地图表单项）',


			// https://developers.google.com/maps/documentation/javascript/directions
			'maps_javascript_api_directions' => '路线服务: 去这儿 - Google Maps Directions API - JavaScript API Directions Web-Service (之客户端服务)',

			'go_there_equivalent_url' => '去这儿 - Google Maps Directions API Equivalent URL',
			'geocoding' => '地理编码服务: 人工地址 <=> 地理坐标',
		];

		$this->load->view('googlemap/index', $data);
	}


	public function maps_javascript_api_show() {
		$data['title'] = 'Google Map Show || marker Clusterer || importing GeoJSON JSONP || StyleOptions || visualization';
		$data['google_ak'] = $this->ak;

		$this->load->view('googlemap/show', $data);
	}

	public function maps_javascript_api_geolocation() {
		$data['title'] = 'Google Map geolocation';
		$data['google_ak'] = $this->ak;

		$this->load->view('googlemap/geolocation', $data);
	}

	public function maps_javascript_api_others() {
		$data['title'] = 'Google Map others';
		$data['google_ak'] = $this->ak;

		$this->load->view('googlemap/others', $data);
	}


	public function maps_javascript_api_places() {
		$data['title'] = 'Google Map Places';
		$data['google_ak'] = $this->ak;

		$this->load->view('googlemap/places', $data);
	}

	public function maps_javascript_api_places_autocomplete() {
		$data['title'] = 'Google Map Places_autocomplete';
		$data['google_ak'] = $this->ak;

		$data['countryMap'] = $this->countryMap;

		$this->load->view('googlemap/places_autocomplete', $data);
	}


	public function maps_javascript_api_events_picker() {
		$data['title'] = 'Google Map Picker || events || geocoding';
		$data['google_ak'] = $this->ak;

		$this->load->view('googlemap/picker', $data);
	}

	public function maps_javascript_api_directions() {
		$data['title'] = 'Google Map directions';
		$data['google_ak'] = $this->ak;

		$this->load->view('googlemap/directions', $data);
	}

	public function go_there_equivalent_url() {
		$data['title'] = 'Google Maps Directions API Equivalent URL';
		$data['google_ak'] = $this->ak;
		$data['baseUrl'] = "https://www.google.com/maps/dir/current+location/";

		$this->load->view('googlemap/equivalent_url', $data);
	}

	
}